// check_users.js
const { Sequelize, DataTypes } = require('sequelize');
const config = require('./config/config.default.js');

// 创建Sequelize实例
const sequelize = new Sequelize(config.sequelize);

async function checkUsers() {
  try {
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('数据库连接成功');

    // 查询用户表
    const [results, metadata] = await sequelize.query('SELECT * FROM users');
    console.log('用户数据:');
    console.log(results);
    
    // 查询用户组织关联表
    const [orgResults, orgMetadata] = await sequelize.query('SELECT * FROM user_organizations');
    console.log('用户组织关联数据:');
    console.log(orgResults);
    
    // 查询组织表
    const [orgList, orgListMetadata] = await sequelize.query('SELECT * FROM organizations');
    console.log('组织数据:');
    console.log(orgList);
  } catch (error) {
    console.error('查询失败:', error);
  } finally {
    await sequelize.close();
  }
}

checkUsers();// check_users.js
const { Sequelize, DataTypes } = require('sequelize');
const config = require('./config/config.default.js');

// 创建Sequelize实例
const sequelize = new Sequelize(config.sequelize);

async function checkUsers() {
  try {
    // 测试数据库连接
    await sequelize.authenticate();
    console.log('数据库连接成功');

    // 查询用户表
    const [results, metadata] = await sequelize.query('SELECT * FROM users');
    console.log('用户数据:');
    console.log(results);
    
    // 查询用户组织关联表
    const [orgResults, orgMetadata] = await sequelize.query('SELECT * FROM user_organizations');
    console.log('用户组织关联数据:');
    console.log(orgResults);
    
    // 查询组织表
    const [orgList, orgListMetadata] = await sequelize.query('SELECT * FROM organizations');
    console.log('组织数据:');
    console.log(orgList);
  } catch (error) {
    console.error('查询失败:', error);
  } finally {
    await sequelize.close();
  }
}

checkUsers();